package cn.efunbox.afw.core.test.snowflakeld;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CyclicBarrier;

public class CycWork implements Runnable {
        private CyclicBarrier cyclicBarrier ;
        private String name ;
        public Set<Long> set;
        public CycWork(CyclicBarrier cyclicBarrier,String name)
        {
            this .name =name;
            this .cyclicBarrier =cyclicBarrier;
        }
        @Override
        public void run() {
            // TODO Auto-generated method stub
            Set<Long>  a=new HashSet<>();
            int j=0;
            Long start=System.currentTimeMillis();
            SnowflakeIdWorker SnowflakeIdUtil=   new SnowflakeIdWorker(0,0);
            System.out.println(SnowflakeIdUtil);
            while (j<10000){
                Long x= SnowflakeIdUtil.nextId();
                a.add(x);
                j++;
            }
            set=new HashSet();
            set.addAll(a);
            System.out.println( (System.currentTimeMillis()-start) +"size ="+a.size()+"ss="+set.size());

        }
    }